﻿<?php

get_header(); ?>

<?php get_sidebar(); ?>
<div id="col3">
	<div class="clearfix" id="col3_content">          
		<div id="main_content">
			<div id="main_content_foot">
			 <?php
				$tags = wp_get_post_tags($post->ID);
				if ($tags) {
					?>
					<?php if (have_posts()) : while (have_posts()) : the_post();?>
			   <?php the_content(); ?>
			 <?php endwhile;  // end of loop
			       endif;
			 ?>
			<div id="detailnew2">
            	<p class="detailnew3">MORE ...</p>
                <ul>
					<?php
				    $tag_ids = array();
				    foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
				
				    $args=array(
				        'tag__in' => $tag_ids,
				        'showposts'=>10, // Số bài muốn hiển thị.
				        'caller_get_posts'=>1,
				    	'order'=>'asc'// Sắp thứ tự
				    );
				    $my_query = new wp_query($args);
				    if( $my_query->have_posts() ) {
				        while ($my_query->have_posts()) {
				            $my_query->the_post();
				        $post_categories = wp_get_post_categories( $post->ID);
						$cats = array();
							
						foreach($post_categories as $c){
							$cat = get_category( $c );
							$cats[] = array( 'name' => $cat->name, 'slug' => $cat->slug );
				        ?>
				            <li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $cat->name; ?>: <?php the_title(); ?></a></li>
				        <?php
        				}
				        }
        				?>
        		</ul>
        	</div>
        				<?php
    				}
				}
			else {
			?>
			<div id="contentpaneopen_faq">
				<div class="contentheading_faq">
					<?php if (have_posts()) : while (have_posts()) : the_post();?>
						<h1><?php the_title();?></h1>
			   			<?php the_content(); ?>
			 		<?php endwhile;  // end of loop
			       	endif;
			 ?>
				</div><!-- #contentheading_faq -->
			</div><!-- #contentpaneopen_faq -->	
			<?php 	
				}
			?>

			</div><!-- #main_content_foot -->
		</div><!-- #main_content -->
<?php get_footer(); ?>
